﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core.DAL.SQL
{
    public class UpdateFromClause : ISqlQueryPart
    {
        private ITable _table;
        private SetClauseList _setList;
        public UpdateFromClause(ITable pTable, SetClauseList pSetList )
        {
            _table = pTable;
            _setList = pSetList;
        }
        #region ISqlQueryPart Members

        public StringBuilder ToSQL()
        {
            var builder = new StringBuilder()
                .AppendLine(" UPDATE [" + _table.Name + "] ")
                .Append(_setList.ToSQL() )
                .AppendLine(" FROM [" + _table.Name + "] " + _table.Alias);

            return builder;
        }

        #endregion
    }
}
